<!DOCTYPE html>
<html>
<head>
    <title>模板分类添加</title>
    <include file='public/head'>
</head>
<body>
	<div class="wrap js-check-wrap" style="padding: 20px 20px 0px 20px;">
		<ul class="nav nav-tabs">
			<php> $currentTab = 16;</php>
			<include file="public/nav" />
		</ul>
	</div>
	<div class="margin-top-20 col-md-5">
		<table class="table table-bordered">
			<thead>
				<tr>
					<th width="50">ID</th>
					<th>分类名称</th>
					<th>分类标识</th>
					<th>操作&nbsp;&nbsp;<a href="javascript:;" class="btn btn-success btn-xs" id="add-btn">添加分类</a></th>
				</tr>
			</thead>
			<tbody>
				<volist name="$list" id="vo">
				<tr>
					<td>{$vo.id}</td>
					<td>{$vo.title}</td>
					<td>{$vo.name}</td>
					<td>
						<a class="btn btn-info btn-sm edit-btn" data-tag="{$vo.id}" data-name="{$vo.name|default=''}"  href="javascript:;">修改</a>

						<a href="{:cmf_plugin_url('Appmarket://template/delClassify')}?id={$vo.id}" class="btn btn-danger btn-sm zy-ajax-confirm" data-msg="确定要删除此分类吗?">删除</a>
					</td>
				</tr>
				</volist>
			</tbody>
		</table>
	</div>
	<div id="edit-panel" style="display: none;">
		<div style="padding: 20px;">
			<label for="name">分类名称</label>
			<input id="name" class="name_input form-control" type="text" name="name" value="" />
		</div>
	</div>

<include file='public/scripts'>

<script src="__STATIC__/js/layui/layui.all.js"></script>
<script src="__STATIC__/js/custom/custom.js"></script>
<script type="text/javascript">
	$('#add-btn').on('click',function(){
		layer.open({
			type:2,
			title:'添加分类名称',
			btn:['添加','取消'],
			area:['400px' , '300px'],
			content:'{:cmf_plugin_url("Appmarket://template/addClassify")}',
			yes:function(index){
				let res = window["layui-layer-iframe" + index].getRes();
				$.post( '{:cmf_plugin_url("Appmarket://template/addClassify")}' , res , function(data){ 
					let icon = ( data.status == 'success' )? 1:5;
					layer.msg( data.message , { icon : icon } );
					if( icon == 1 ){
						setTimeout( function(){
							window.location.reload();
						},1200);
					}
				} , 'json' );
			}
		});
	});
	$('.edit-btn').on('click',function(){
		let id = $( this ).data('tag');
		layer.open({
			type:2,
			title:'添加分类名称',
			btn:['添加','取消'],
			area:['400px' , '300px'],
			content:'{:cmf_plugin_url("Appmarket://template/editClassify")}?id='+id,
			yes:function(index){
				let res = window["layui-layer-iframe" + index].getRes();
				res [ 'id' ] = id;
				$.post( '{:cmf_plugin_url("Appmarket://template/editClassify")}' , res , function(data){ 
					let icon = ( data.status == 'success' )? 1:5;
					layer.msg( data.message , { icon : icon } );
					if( icon == 1 ){
						setTimeout( function(){
							window.location.reload();
						},1200);
					}
				} , 'json' );
			}
		});
	});
</script>
</body>
</html>